package com.shop.servlet.impl;

import com.shop.dao.BaseDao;
import com.shop.dao.impl.TOrderDaoImpl;
import com.shop.entity.ShowPageT;
import com.shop.servlet.BaseServlet;

import java.sql.SQLException;
import java.util.List;

/**
 * com.shop.servlet.impl文档说明
 *
 * @author Angluzha
 * @version 2022/9/14
 */
public class BaseServletImpl<T> implements BaseServlet<T> {
    protected BaseDao dao;
    @Override
    public T selectOne(T t) {
        try {
            return (T) dao.selectOne(t);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public boolean update(T t) {
        return dao.update(t);
    }

    @Override
    public boolean insert(T t) {
        return dao.insert(t);
    }

    @Override
    public boolean deleteById(Integer id) {
        return dao.deleteById(id);
    }

    @Override
    public List<T> selectAll() {
        try {
            return dao.selectAll();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public ShowPageT<T> selectPage(ShowPageT<T> page) {
        try {
            return dao.selectPage(page);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public boolean delCheck(List<Integer> list) {
        return dao.delCheck(list)>0;
    }
}
